<%@ include file="/WEB-INF/jspf/directive/taglib.jspf" %>

<html>

<c:set var="title">
	<fmt:message key="createpayment.title.text" />
</c:set>
<%@ include file="/WEB-INF/jspf/head.jspf" %>

<body>

	<%-- You should not better read the code below.. --%>

	<div class="container small-form">
		<form action="controller">
			<h3><fmt:message key="createpayment.label.title" /></h3>
			<input type="hidden" name="command" value="continuePaymentCreation">
			
			<p class="lead"><fmt:message key="createpayment.label.chooseuser" /></p>
			<select name="user" class="txt-fld input-block-level">

				<c:forEach var="usr" items="${sessionScope['users']}">
					<option><c:out value="${usr.login}"></c:out></option>
				</c:forEach>

			</select>
			<button type="submit" name="setUser" class="btn btn-large btn-block">
				<fmt:message key="createpayment.button.setuser" />
			</button><br><br>
			
			<c:if test="${not empty sessionScope['targetUser'] || not empty sessionScope['senderAccount'] ||
					not empty sessionScope['recieverAccount']}">
				<c:choose>
					<c:when test="${not empty sessionScope['senderAccounts']}">
						<p class="lead"><fmt:message key="createpayment.label.choosehisaccount" /></p>
						<select name="senderAccount" class="txt-fld input-block-level">
							
							<c:forEach var="acc" items="${sessionScope['senderAccounts']}">
								<option
									<c:if test="${sessionScope.senderAccount.id == acc.id}">
										selected
									</c:if>
								><c:out value="${acc.id}"></c:out></option>
							</c:forEach>
		
						</select>
						<button 
							type="submit" 
							name="setSenderAcc" 
							class="btn btn-large btn-block">
							<fmt:message key="createpayment.button.sethisaccount" />
						</button><br><br>
					</c:when>
					<c:otherwise>
						<h3><fmt:message key="createpayment.label.userhasnoaccounts" /></h3>
					</c:otherwise>
				</c:choose>
			</c:if>
				
			<c:if test="${not empty sessionScope['senderAccount'] || not empty sessionScope['recieverAccount']}">
				<c:choose>
					<c:when test="${not empty sessionScope['recieverAccounts']}">
						<p class="lead"><fmt:message key="createpayment.label.chooseyouraccount" /></p>
						<select name="recieverAccount" class="txt-fld input-block-level">
	
							<c:forEach var="acc" items="${sessionScope['recieverAccounts']}">
								<option
									<c:if test="${sessionScope.recieverAccount.id == acc.id}">
										selected
									</c:if>
								><c:out value="${acc.id}"></c:out></option>
							</c:forEach>
	
						</select>	
						<button 
							type="submit" 
							name="setRecieverAcc" 
							class="btn btn-large btn-block">
							<fmt:message key="createpayment.button.setrecieveraccount" />
						</button><br><br>
						
					</c:when>
					<c:otherwise>
						<h3><fmt:message key="createpayment.label.noappropaccounts" /></h3>
					</c:otherwise>
				</c:choose>
			</c:if>
			
			<c:if test="${not empty sessionScope['recieverAccount']}">
				<p class="lead"><fmt:message key="createpayment.label.setpaymentamount" />:</p>
				<input 
					name="value" class="txt-fld input-block-level" type="number"
					placeholder="Value" value="100"><br><br>
				<button 
					name="makePayment" 
					type="submit" 
					class="btn btn-large btn-block">
					<fmt:message key="createpayment.button.askforpayment" />
				</button>
			</c:if>
		</form>
		
		<a href="controller?command=browseUserPage" class="btn btn-large btn-block">
			<fmt:message key="createpayment.button.back" />
		</a>
	</div>

</body>
</html>